<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="time-schedule" mode="admin-time-form">
	<div class="calendar-head">
		<h2>Edit Time Schedule for <strong><xsl:value-of select="entry/weekday[@handle =$entry-id]"/></strong></h2>
	</div>
	
	<div class="admin-message">
		<xsl:if test="/data/events/admin-edit-time-schedule/@result = 'error'">
			<h4>
				<xsl:value-of select="/data/events/admin-edit-time-schedule/@result"/>
				<xsl:text>. The following errors were encountered when attempting to save this client:</xsl:text>
				<xsl:value-of select="/data/events/admin-edit-time-schedule/filter[@name = 'send-email']"/>
			</h4>
			
			<xsl:if test="/data/events/admin-edit-time-schedule/available-times/@type = 'missing'">
				<p>
					<strong>Available Times</strong>
					<xsl:text> is a required field.</xsl:text>
				</p>
			</xsl:if>
			<xsl:if test="/data/events/admin-edit-time-schedule/session-length/@type = 'missing'">
				<p>
					<strong>Session Length</strong>
					<xsl:text> is a required field.</xsl:text>
				</p>
			</xsl:if>
		</xsl:if>
		<xsl:if test="/data/events/admin-edit-time-schedule/@result = 'success'">
			<h4>
				<xsl:value-of select="/data/events/admin-edit-time-schedule/@result"/>
				<xsl:text>. </xsl:text>
				<xsl:value-of select="/data/events/admin-edit-time-schedule/message"/>
			</h4>
		</xsl:if>
	</div>
	
	<p><strong>Please note:</strong> changes to a day's time schedule will preserve existing client appointments, which may result in appointments conflicting with each other. You may need to inform clients of the potential conflict, and re-book those appointments on other dates.</p>
	
	<form method="post" action="" enctype="multipart/form-data">
		<input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
		<label>Session Length
			<select name="fields[session-length]">
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/session-length/item/@handle = 'none'">
						<option value="None" selected="selected">None</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="None">None</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/session-length/item/@handle = '1-hour'">
						<option value="1 hour" selected="selected">1 hour</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="1 hour">1 hour</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/session-length/item/@handle = '1-hour-15-mins'">
						<option value="1 hour 15 mins" selected="selected">1 hour</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="1 hour 15 mins">1 hour 15 mins</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/session-length/item/@handle = '1-hour-30-mins'">
						<option value="1 hour 30 mins" selected="selected">1 hour 30 mins</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="1 hour 30 mins">1 hour 30 mins</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/session-length/item/@handle = '2-hours'">
						<option value="2 hours" selected="selected">2 hours</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="2 hours">2 hours</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/session-length/item/@handle = '2-hours-30-mins'">
						<option value="2 hours 30 mins" selected="selected">2 hours 30 mins</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="2 hours 30 mins">2 hours 30 mins</option>
					</xsl:otherwise>
				</xsl:choose>
			</select>
		</label>
		<label>Available Times
			<select name="fields[available-times][]" multiple="multiple" style="width: 100%; height: 350px">
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = 'None'">
						<option value="None" selected="selected">None</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="None">None</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '08:00'">
						<option value="08:00" selected="selected">8:00am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="08:00">8:00am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '08:15'">
						<option value="08:15" selected="selected">8:15am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="08:15">8:15am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '08:30'">
						<option value="08:30" selected="selected">8:30am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="08:30">8:30am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '08:45'">
						<option value="08:45" selected="selected">8:45am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="08:45">8:45am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '09:00'">
						<option value="09:00" selected="selected">9:00am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="09:00">9:00am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '09:15'">
						<option value="09:15" selected="selected">9:15am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="09:15">9:15am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '09:30'">
						<option value="09:30" selected="selected">9:30am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="09:30">9:30am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '09:45'">
						<option value="09:45" selected="selected">9:45am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="09:45">9:45am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '10:00'">
						<option value="10:00" selected="selected">10:00am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="10:00">10:00am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '10:15'">
						<option value="10:15" selected="selected">10:15am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="10:15">10:15am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '10:30'">
						<option value="10:30" selected="selected">10:30am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="10:30">10:30am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '10:45'">
						<option value="10:45" selected="selected">10:45am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="10:45">10:45am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '11:00'">
						<option value="11:00" selected="selected">11:00am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="11:00">11:00am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '11:15'">
						<option value="11:15" selected="selected">11:15am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="11:15">11:15am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '11:30'">
						<option value="11:30" selected="selected">11:30am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="11:30">11:30am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '11:45'">
						<option value="11:45" selected="selected">11:45am</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="11:45">11:45am</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '12:00'">
						<option value="12:00" selected="selected">12:00pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="12:00">12:00pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '12:15'">
						<option value="12:15" selected="selected">12:15pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="12:15">12:15pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '12:30'">
						<option value="12:30" selected="selected">12:30pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="12:30">12:30pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '12:45'">
						<option value="12:45" selected="selected">12:45pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="12:45">12:45pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '13:00'">
						<option value="13:00" selected="selected">1:00pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="13:00">1:00pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '13:15'">
						<option value="13:15" selected="selected">1:15pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="13:15">1:15pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '13:30'">
						<option value="13:30" selected="selected">1:30pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="13:30">1:30pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '13:45'">
						<option value="13:45" selected="selected">1:45pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="13:45">1:45pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '14:00'">
						<option value="14:00" selected="selected">2:00pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="14:00">2:00pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '14:15'">
						<option value="14:15" selected="selected">2:15pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="14:15">2:15pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '14:30'">
						<option value="14:30" selected="selected">2:30pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="14:30">2:30pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '14:45'">
						<option value="14:45" selected="selected">2:45pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="14:45">2:45pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '15:00'">
						<option value="15:00" selected="selected">3:00pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="15:00">3:00pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '15:15'">
						<option value="15:15" selected="selected">3:15pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="15:15">3:15pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '15:30'">
						<option value="15:30" selected="selected">3:30pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="15:30">3:30pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '15:45'">
						<option value="15:45" selected="selected">3:45pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="15:45">3:45pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '16:00'">
						<option value="16:00" selected="selected">4:00pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="16:00">4:00pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '16:15'">
						<option value="16:15" selected="selected">4:15pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="16:15">4:15pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '16:30'">
						<option value="16:30" selected="selected">4:30pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="16:30">4:30pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '16:45'">
						<option value="16:45" selected="selected">4:45pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="16:45">4:45pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '17:00'">
						<option value="17:00" selected="selected">5:00pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="17:00">5:00pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '17:15'">
						<option value="17:15" selected="selected">5:15pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="17:15">5:15pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '17:30'">
						<option value="17:30" selected="selected">5:30pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="17:30">5:30pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '17:45'">
						<option value="17:45" selected="selected">5:45pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="17:45">5:45pm</option>
					</xsl:otherwise>
				</xsl:choose>
				<xsl:choose>
					<xsl:when test="entry[weekday/@handle = $entry-id]/available-times/item = '18:00'">
						<option value="18:00" selected="selected">6:00pm</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="18:00">6:00pm</option>
					</xsl:otherwise>
				</xsl:choose>
			</select>
		</label>
		<input name="id" type="hidden" value="{entry[weekday/@handle = $entry-id]/@id}" />
		<input name="action[admin-edit-time-schedule]" type="submit" value="Save Changes" />
	</form>
</xsl:template>

<!--
	called from 'get-admin-menu.xsl'
-->
<xsl:template match="time-schedule" mode="schedule-list">
	<select id="admin_time-schedule">
		<option value="Edit a client">select a day</option>
		<option disabled="disabled" value="">--------------</option>
		<xsl:apply-templates select="entry" mode="list"/>
	</select>
</xsl:template>

<xsl:template match="time-schedule/entry" mode="list">
	<xsl:choose>
		<xsl:when test="weekday/@handle = $entry-id and $current-page = 'admin-time-schedule'">
			<option value="{weekday/@handle}" selected="selected">
				<xsl:value-of select="weekday"/>
			</option>
		</xsl:when>
		<xsl:otherwise>
			<option value="{weekday/@handle}">
				<xsl:value-of select="weekday"/>
			</option>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

		


</xsl:stylesheet>